
import java.io.*;
import java.util.ArrayList;


/**
 * Class that handle the process of write the content of arrayList to the file
 */
public class writeFile {
    
    public static boolean writeTo( String fileName, ArrayList<String> data, boolean option) throws IOException{

        // put FileOutputStream( fileName, true) --> append file,
        // If not put "true" --> rewrite file
    	FileOutputStream fileOut;
    	if (option) 
    		fileOut = new FileOutputStream(fileName, true);
    	else
    		fileOut = new FileOutputStream(fileName);
    		
        PrintStream printS = new PrintStream( fileOut);

        for ( int i = 0; i < data.size() ; i ++ )
        {
             if (data.get(i) == null)
                  break;
             printS.println(data.get(i));
        }

        fileOut.close();
        printS.close();

        return true;
    }

}
